package service.Impl;

import dao.BookDao;
import dao.Impl.BookDaoImpl;

import service.BookService;
import utils.page;


/**
 * @author wangying
 * @date 2025/2/21 16:25
 * title
 */
public class BookServiceImpl implements BookService {
    BookDao dao = new BookDaoImpl();

    @Override
    public page findpage(String name, int sort, int pageNo, int pageSize) {
       page page=new page();
       page.setCurrPageNo(pageNo);
       page.setPageSize(pageSize);
      int count=dao.count(name,sort);
       page.setTotalCount(count);
       if (count%pageSize==0){
           page.setGetTotalCount(count/pageSize);
       }else {
           page.setGetTotalCount(count/pageSize+1);
       }
       page.setData(dao.getBookBySortAndName(name,sort,(pageNo-1)*pageSize,pageSize));
        return page;
    }
}
